﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;

namespace TheardLearnWeb.Learn
{
    public partial class ThreadPoolLearn : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.divContent.InnerHtml += string.Format("Main thread:queueing an asynchronous operation</br>");
            ThreadPool.QueueUserWorkItem(ComputerBoundOp, 5);
            this.divContent.InnerHtml += string.Format("Main Thread:Doing other work here...</br>");
            Thread.Sleep(10000);
            this.divContent.InnerHtml += string.Format("Hit <Enter> to end this program...</br>");
        }

        public void ComputerBoundOp(Object state)
        {
            this.divContent.InnerHtml += string.Format("In ComputerBoundOp:state={0}</br>", state);
            Thread.Sleep(1000);

        }
    }
}